package com.yc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * Web控制器，用于处理Vue Router的回退路由
 * 确保在history模式下，所有非API路径都能正确重定向到index.html
 */
@Controller
public class WebController {

    /**
     * 处理所有非API路径的GET请求
     * 只处理直接路径，避免捕获资源文件
     * @return index.html视图
     */
    @RequestMapping(value = {"/", "/product-management", "/product-crawler"}, method = RequestMethod.GET)
    public String handleAppRoutes() {
        return "forward:/index.html";
    }
}